package hichecker;

import hichecker.controller.Config;
import hichecker.controller.MainController;
import hichecker.tools.logging.CustomLogger;
import hichecker.ui.MainFrame;

import java.io.IOException;

import javax.swing.UIManager;

import org.apache.log4j.Logger;

public class HiChecker {
	private static Logger logger = Logger.getLogger(HiChecker.class);
	private static MainController controller;

	public static void main(String[] args) {
		// init logger, exit programm on fail
		try {
			CustomLogger.setup();
		} catch (IOException e) {
			System.err.println("Can't create log file. System exit.");
			System.exit(-1);
		}

		// start message
		logger.info(Config.PROGRAM_NAME + " v" + Config.PROGRAM_VERSION + " started");

		// set NimbusLookAndFeel
		try {
			UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch (Exception e) {
			logger.error("Unable to set NimbusLookAndFeel.", e);
		}

		// check if only limited access
		boolean fullAccess = true;
		if (args.length > 0 && args[0].equals("--limited"))
			fullAccess = false;

		// start hichecker
		controller = new MainController(fullAccess);
		new MainFrame(controller);

	}
}
